<!--Page.125-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        input.err {
            border-color: #B94A48;
        }
        .help {
            color: #B94A48;
        }

    </style>
    <title>repeat number</title>

    <!-- icons -->
    <link rel="icon" href="../../../lib/image/favicon.ico"/>
    <link rel="shortcut icon" href="../../../lib/image/favicon.ico"/>
</head>
<body>
<table class="orderList">
    <thead>
    <tr>
        <th>Retailer Id</th>
        <th>Retailer Name</th>
        <th>Sort Order</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>43523</td>
        <td>gsfgag</td>
        <td class="sortOrder">
           <input id="c16_order" name="order" type="text" value="1"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>22200586</td>
        <td>New Amazon</td>
        <td class="sortOrder">
           <input id="c21_order" name="order" type="text" value="2"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>1212122</td>
        <td>1212122</td>
        <td class="sortOrder">
           <input id="c26_order" name="order" type="text" value="3"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>10750</td>
        <td>Crow1111111112222222</td>
        <td class="sortOrder">
           <input id="c31_order" name="order" type="text" value="4"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>10340</td>
        <td>REI</td>
        <td class="sortOrder">
           <input id="c36_order" name="order" type="text" value="5"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>199000000</td>
        <td>Crow</td>
        <td class="sortOrder">
           <input id="c41_order" name="order" type="text" value="6"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>2056958</td>
        <td>Crow</td>
        <td class="sortOrder">
           <input id="c46_order" name="order" type="text" value="7"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>545</td>
        <td>fdasf</td>
        <td class="sortOrder">
           <input id="c51_order" name="order" type="text" value="8"/><span class="help"></span>
        </td>
    </tr>
    <tr>
        <td>10275</td>
        <td>Williams-Sonoma</td>
        <td class="sortOrder">
           <input id="c56_order" name="order" type="text" value="9"/><span class="help"></span>
        </td>
    </tr>
    </tbody>
</table>
<script src="../../../lib/js/jquery-1.9.0.min.js"></script>
<script>
(function($){

    var Valid=function(element,message){
        this.elem = $(element);
        this.msg=message;
        this.items=this.elem.find('input');
        this.len=this.items.size();
        this.init()
    };

    Valid.prototype={
        constructor:Valid,

        init:function(){
            var _this=this;
            this.elem.on('blur','input',function(e){
                _this.targetInput= $(e.target);
                _this.elem.find('.help').remove();
                _this.items.removeClass('err');
                _this.check();

            })
        },

        check:function(){
            var _this=this,arr = this.getValue(), res = [], len = this.len;
            for (var i = 0; i < len;) {
                var count = 0;
                for (var j = i; j < len; j++) {
                    if (arr[i] == arr[j]) {
                        count++
                    }
                }
                if (count >= 2) {
                    res.push([arr[i], count]);
                    $.each(this.items, function () {
                        if ($(this).val() == arr[i]) {
                            if ($(this).val() == res[0].slice(0, 1)) {
                                $(this).addClass('err').after('<span class="help">'+_this.msg+'</span>');
                            }
                        }
                    })
                }
                i += count;
            }

//            var tarVal=_this.targetInput.val(),
//                pos=arr.indexOf(tarVal);
//            while(pos>-1){
//                res.push(pos);
//                pos=arr.indexOf(tarVal,pos+1)
//            }
//            if(res.length>=2){
//                for(var t=0;t<len;t++){
//                    this.items.eq(res[t]).addClass('err').after('<span class="help">'+_this.msg+'</span>');
//                }
//            }

        },

        getValue:function(){
            var arr=[];
            $.each(this.elem.find('input'),function(){
                arr.push($(this).val())
            });
            return arr
        }

    };

    var valid=new Valid('.orderList','repeat number');


})(window.jQuery)

</script>
</body>
</html>